class ImageAttachment {
  final String id;
  final String url;

  ImageAttachment({
    required this.id,
    required this.url,
  });

  factory ImageAttachment.fromJson(Map<String, dynamic> json) {
    return ImageAttachment(
      id: json['id'],
      url: json['url'],
    );
  }
}

//报修项目
class RepairItem {
  String id;
  String name;
  RepairItem({required this.id, required this.name});
  //json
  factory RepairItem.fromJson(Map<String, dynamic> json) {
    return RepairItem(id: json['id'], name: json['name']);
  }
}

// 查询报修列表
///返回数据
class RepairListResponse {
  ///总页数
  int pageTotal;

  ///数据
  List<RepairListRow> rows;

  ///总条数
  int total;

  RepairListResponse({
    required this.pageTotal,
    required this.rows,
    required this.total,
  });

  factory RepairListResponse.fromJson(Map<String, dynamic> json) {
    return RepairListResponse(
      pageTotal: json['pageTotal'],
      rows: (json['rows'] as List<dynamic>)
          .map((item) => RepairListRow.fromJson(item as Map<String, dynamic>))
          .toList(),
      total: json['total'],
    );
  }
}

class RepairListRow {
  ///预约日期
  String appointment;

  ///附件信息，0-9个
  List<ImageAttachment> attachment;

  ///问题描述-做多200字
  String description;

  ///房屋信息id
  String houseId;

  ///主键id
  String id;

  ///手机号
  String mobile;

  ///维修项目id
  String repairItemId;

  ///维修项目名称
  String repairItemName;

  ///维修状态码：1受理中2上门中3已完成0已取消
  int status;

  RepairListRow({
    required this.appointment,
    required this.attachment,
    required this.description,
    required this.houseId,
    required this.id,
    required this.mobile,
    required this.repairItemId,
    required this.repairItemName,
    required this.status,
  });

  factory RepairListRow.fromJson(Map<String, dynamic> json) {
    return RepairListRow(
      id: json['id'],
      appointment: json['appointment'],
      attachment: (json['attachment'] as List<dynamic>)
          .map((item) => ImageAttachment.fromJson(item as Map<String, dynamic>))
          .toList(),
      description: json['description'],
      houseId: json['houseId'],
      mobile: json['mobile'],
      repairItemId: json['repairItemId'],
      repairItemName: json['repairItemName'],
      status: json['status'],
    );
  }
}
